# Maintainer: Maxime Gauduin <alucryd@archlinux.org>
# Contributor: Gerard Ribugent <ribugent@gmail.com>

pkgname=jenv
pkgver=0.5.6
pkgrel=1
pkgdesc='Manage your Java environment'
arch=(any)
url=https://github.com/jenv/jenv
license=(MIT)
depends=(bash)
makedepends=(git)
optdepends=(
  'bash-completion: Bash completion support'
  'fish: Fish support'
  'zsh: Zsh support'
)
_tag=1518864ceb0ef95c609ba2dbde064e04b8e5f419
source=(git+https://github.com/jenv/jenv.git#tag=${_tag})
b2sums=(SKIP)

prepare() {
  cd jenv
  # fish has no hash command
  git cherry-pick -n 4af54a52c6d2758a493315e99c7bcaad5bda3a2c
}

pkgver() {
  cd jenv
  git describe --tags | sed 's/-/.r/; s/-g/./'
}

package() {
  install -dm 755 "${pkgdir}"/usr/{bin,share/{fish,jenv}}
  cp -dr --no-preserve=ownership jenv/{available-plugins,libexec} "$pkgdir"/usr/share/jenv/
  cp -dr --no-preserve=ownership jenv/fish "${pkgdir}"/usr/share/fish/vendor_functions.d
  ln -s /usr/share/jenv/libexec/jenv "${pkgdir}"/usr/bin/
  install -Dm 644 jenv/completions/jenv.bash "${pkgdir}"/usr/share/bash-completion/completions/jenv
  install -Dm 644 jenv/completions/jenv.fish -t "${pkgdir}"/usr/share/fish/vendor_completions.d/
  install -Dm 644 jenv/completions/jenv.zsh "${pkgdir}"/usr/share/zsh/site-functions/_jenv
  install -Dm 644 jenv/LICENSE -t "${pkgdir}"/usr/share/licenses/jenv/
}

# vim: ts=2 sw=2 et:
